/*
 * Created on 2005-3-23
 *
 * Copyright: Bluejay Networks Inc. 2005
 *
 * This software is the proprietary information of Bluejay Networks Inc. 
 * 
 * Use is subject to license terms.
 * 
 */
package com.ims.iaa.swf.datatype;

//HasScale				hasScale = UB[1]					Has scale values if equal to 1			
//NScaleBits			If hasScale nScaleBits = UB[5]		Bits in each scale value field			
//ScaleX				If hasScale FB[nScaleBits]			X scale value			
//ScaleY				If hasScale FB[nScaleBits]			Y scale value			
//HasRotate				hasRotate = UB[1]					Has rotate and skew values if equal to 1			
//NRotateBits			If hasRotate nRotateBits = UB[5]	Bits in each rotate value field			
//RotateSkew0			If hasRotate FB[nRotateBits]		First rotate and skew value			
//RotateSkew1			If hasRotate FB[nRotateBits]		Second rotate and skew value			
//NTranslateBits		nTranslateBits = UB[5]				Bits in each translate value field			
//TranslateX			SB[nTranslateBits]					X translate value in twips			
//TranslateY			SB[nTranslateBits]					Y translate value in twips			
//////////////////The start of a MATRIX record must be byte-aligned
/**
 * @author ShengMengBai
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class Matrix {
    private int m_iStart = 0;
    private byte[] m_bytData = null;
    public Matrix(byte[] bytData, int iStart){
        m_bytData = bytData;
        m_iStart = iStart;
        parse();
    }
    private void parse(){
        int iStart = m_iStart;
        int iNBits = 0;
        int iSignValue = 0x80;
        //hasScale
        iNBits++;
        m_iByteSize++;
        if((m_bytData[iStart] & iSignValue) != 0){
    		int iBits = (m_bytData[iStart] & 0x7F) >> 2;
            m_iByteSize = m_iByteSize + 8;
        }
        iStart = m_iStart + m_iByteSize;
        
        //hasRotate
        m_iByteSize++;
        if((m_bytData[iStart] & iSignValue) != 0){
    		int iBits = (m_bytData[iStart] & 0x7F) >> 2;
            m_iByteSize = m_iByteSize + 8;
        }
        iStart = m_iStart + m_iByteSize;

        //NTranslateBits
    	int iBits = (m_bytData[iStart] & 0xFF) >> 3;
        m_iByteSize++;
        m_iByteSize += (iBits / 8) * 2;
		if(iBits % 8 != 0){
		    m_iByteSize += 2;
		}
    }
    public int getHasScale(){
        throw new RuntimeException("unImplement exception.");
    	//return m_iHasScale;
    }
    public int getNScaleBits(){
        throw new RuntimeException("unImplement exception.");
    	//return m_iNScaleBits;
    }
    public int getScaleX(){
        throw new RuntimeException("unImplement exception.");
    	//return m_iScaleX;
    }
    public int getScaleY(){
        throw new RuntimeException("unImplement exception.");
    	//return m_iScaleY;
    }
    public int getHasRotate(){
        throw new RuntimeException("unImplement exception.");
    	//return m_iHasRotate;
    }
    public int getNRotateBits(){
        throw new RuntimeException("unImplement exception.");
    	//return m_iNRotateBits;
    }
    public int getRotateSkew0(){
        throw new RuntimeException("unImplement exception.");
    	//return m_iRotateSkew0;
    }
    public int getRotateSkew1(){
        throw new RuntimeException("unImplement exception.");
    	//return m_iRotateSkew1;
    }
    public int getNTranslateBits(){
        throw new RuntimeException("unImplement exception.");
    	//return m_iNTranslateBits;
    }
    public int getTranslateX(){
        throw new RuntimeException("unImplement exception.");
    	//return m_iTranslateX;
    }
    public int getTranslateY(){
        throw new RuntimeException("unImplement exception.");
    	//return m_iTranslateY;
    }
    public int getByteSize(){
    	return m_iByteSize;
    }

    private int m_iHasScale;
    private int m_iNScaleBits;
    private int m_iScaleX;
    private int m_iScaleY;
    private int m_iHasRotate;
    private int m_iNRotateBits;
    private int m_iRotateSkew0;
    private int m_iRotateSkew1;
    private int m_iNTranslateBits;
    private int m_iTranslateX;
    private int m_iTranslateY;
    private int m_iByteSize;
}
